#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>

using namespace std;

class Solution {
public:
    int getLongestPalindrome(string A) {
        int n = A.size();

        int ret = 0;

        for (int i = 0; i < A.size(); i++) {
            int left = i - 1, right = i + 1;
            while (left >= 0 && right <= n && A[left] == A[right]) {
                left--;
                right++;
            }
            ret = max(ret, right - left - 1);

            left = i, right = i + 1;
            while (left >= 0 && right <= n && A[left] == A[right]) {
                left--;
                right++;
            }
            ret = max(ret, right - left - 1);
        }

        return ret;
    }
};